package com.qiaofang.collectmanage.service.util;
import com.qiaofang.collectmanage.dao.domain.CrawlerTask;
import com.qiaofang.collectmanage.stub.bean.CrawlerTaskDTO;
import com.qiaofang.collectmanage.stub.bean.SaveCrawlerTaskDTO;
import com.qiaofang.collectmanage.stub.bean.UpdateCrawlerTaskDTO;
import com.qiaofang.collectmanage.stub.bean.ListCrawlerTaskDTO;

/**
* Created by generator on 2018-8-1 13:49:21
*/
public class CrawlerTaskConvert {

    private CrawlerTaskConvert(){}

     public static  CrawlerTask  convertDTO2Domain(CrawlerTaskDTO taskDTO){
     	if(taskDTO == null){
           return null;
         }
         CrawlerTask task = new  CrawlerTask();
           task.setId(taskDTO.getId());
           task.setUuid(taskDTO.getUuid());
           task.setTaskName(taskDTO.getTaskName());
           task.setSparkParam(taskDTO.getSparkParam());
           task.setStartPageNum(taskDTO.getStartPageNum());
           task.setEndPageNum(taskDTO.getEndPageNum());
           task.setCreatedUserUuid(taskDTO.getCreatedUserUuid());
           task.setUpdatedUserUuid(taskDTO.getUpdatedUserUuid());
        return task;
     }

    public static  CrawlerTask  convertSaveDTO2Domain(SaveCrawlerTaskDTO taskDTO){
        if(taskDTO == null){
           return null;
        }
        CrawlerTask  task = new  CrawlerTask();
        task.setUuid(taskDTO.getUuid());
        task.setTaskName(taskDTO.getTaskName());
        task.setSparkParam(taskDTO.getSparkParam());
        task.setStartPageNum(taskDTO.getStartPageNum());
        task.setEndPageNum(taskDTO.getEndPageNum());
        return task;
    }

    public static  CrawlerTask  convertUpdateDTO2Domain(UpdateCrawlerTaskDTO taskDTO){
        if(taskDTO == null){
            return null;
        }
        CrawlerTask  task = new  CrawlerTask();
        task.setId(taskDTO.getId());
        task.setUuid(taskDTO.getUuid());
        task.setTaskName(taskDTO.getTaskName());
        task.setSparkParam(taskDTO.getSparkParam());
        task.setStartPageNum(taskDTO.getStartPageNum());
        task.setEndPageNum(taskDTO.getEndPageNum());
        return task;
    }


    public static  CrawlerTask  convertListDTO2Domain(ListCrawlerTaskDTO taskDTO){
        if(taskDTO == null){
            return null;
        }
        CrawlerTask  task = new  CrawlerTask();
        task.setId(taskDTO.getId());
        task.setUuid(taskDTO.getUuid());
        task.setTaskName(taskDTO.getTaskName());
        task.setSparkParam(taskDTO.getSparkParam());
        task.setStartPageNum(taskDTO.getStartPageNum());
        task.setEndPageNum(taskDTO.getEndPageNum());
        return task;
    }

     public static CrawlerTaskDTO convertDomain2DTO(CrawlerTask task){
     	if(task ==null){
           return null;
        }
        CrawlerTaskDTO taskDTO = new CrawlerTaskDTO();
            taskDTO.setId(task.getId());
            taskDTO.setUuid(task.getUuid());
            taskDTO.setTaskName(task.getTaskName());
            taskDTO.setSparkParam(task.getSparkParam());
            taskDTO.setStartPageNum(task.getStartPageNum());
            taskDTO.setEndPageNum(task.getEndPageNum());
            taskDTO.setCreatedUserUuid(task.getCreatedUserUuid());
            taskDTO.setUpdatedUserUuid(task.getUpdatedUserUuid());
            taskDTO.setCreatedTime(task.getCreatedTime());
            taskDTO.setUpdatedTime(task.getUpdatedTime());
          return taskDTO;
     }

}
